<template>
  <el-dialog :visible.sync="value" :before-close="cancel">
    <template slot="title">
      {{this.step === 'success-manual' ? '申请手动成功' : '申请手动失败'}}
    </template>
    <el-form :model="form" ref="withdrawForm" :rules="withdrawRule" :label-width="formLabelWidth">
      <el-tip style="padding: 10px 0 10px 150px;" v-if="this.step === 'success-manual'">确定 <span style="color:#e6a23c;">{{rowData.name}}</span>
        的提款设置为手动成功状态吗?
      </el-tip>
      <el-tip style="padding: 10px 0 10px 150px;" v-else>确定 <span style="color:#e6a23c;">{{rowData.name}}</span>
        的提款设置为手动失败状态吗?
      </el-tip>
      <el-form-item label="备注" prop="remark">
        <el-col :span="16">
          <el-input type="textarea" v-model="form.remark"></el-input>
        </el-col>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancel">取 消</el-button>
      <el-button type="primary" @click="doSave({action: 'saveForm', form: 'withdrawForm'})" :loading="loading">确 定
      </el-button>
    </div>
  </el-dialog>
</template>

<script>

  import {form} from '@/build'
  import {manualOperation,} from '@/services/api/withdraw';

  export default {
    name: "auto-user-withdraw-dialog",
    props: ['value','step', 'rowData'],
    mixins: [form],
    data() {
      return {
        formLabelWidth: '150px',
        form: {
          type: 1,
          remark: '',
          orderId: this.rowData.orderId
        },
        withdrawRule: {
          remark: [
            {required: true, message: '备注不能为空', trigger: 'blur'},
          ],
        },
      }
    },
    computed: {},

    mounted() {
      this.bindSave(manualOperation, 'saveForm', 'form', {
        beforeSend: data => {
          switch (this.step) {
            case 'success-manual':
              data.type = 1;
              break
            case 'fail-manual':
              data.type = 2;
              break
          }
          return data
        },
        afterSuccess: () => {
          this.cancel()
          this.$parent.gridSearch()
        }
      });

    },
    methods: {
      cancel() {
        this.$emit('input', false);
      },
    },

  }
</script>

<style lang="scss" scoped>

</style>
